package com.czxy.controller;

import com.czxy.domain.City;
import com.czxy.service.CityService;
import com.czxy.vo.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/city")
public class CityController {
    @Autowired
    private CityService cityService;



    @GetMapping("/all")
    public BaseResult findAll(){
        List<City> address = cityService.getAddress();
        return BaseResult.ok(address);
    }

    @GetMapping("/{parentId}")
    public BaseResult getByParentId(@PathVariable("parentId") String parentId){
        List<City> childList = cityService.findByParentId(parentId);
        return BaseResult.ok(childList);
    }

}
